package com.example.mp.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mp.entity.Kk;
import com.example.mp.entity.TabStudent;
import com.example.mp.service.IKkService;
import com.example.mp.util.Result;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zf
 * @since 2023-02-04
 */
@RestController
@CrossOrigin
@RequestMapping("/kk")
public class KkController {
    @Resource
    private IKkService kkService;
        @GetMapping("getAll")
            public String getAll(){
                return "8081";
        }
        @GetMapping("getAllPage")
    public Result getAllPage(Integer curr,Integer size,String name, String inter){
            Page page = new Page(curr,size);
            QueryWrapper queryWrapper = new QueryWrapper();
            if(StringUtils.isNotBlank(name)){
                queryWrapper.eq("name",name);
            }
            if(StringUtils.isNotBlank(inter)){
                queryWrapper.like("inter",inter);
            }
            Page list = kkService.page(page,queryWrapper);
            return  new Result(list);
        }
    @PostMapping("addstu")
    public Result addStu(Kk kk){
        System.out.println("kk = " +kk);
        boolean b = kkService.saveOrUpdate(kk);
        return new Result(b);
    }

}

